//
//  NewWalletStore.m
//  NewPro
//
//  Created by RYX on 2019/4/11.
//  Copyright © 2019 何荧红. All rights reserved.
//

#import "NewWalletStore.h"
#import "NewWalletModel.h"
#import "TXModel.h"
#import "NewWalletList.h"

@implementation NewWalletStore

#pragma mark - 获取账户余额
- (void)getAccountBalanceWithCustomId:(NSString *)customId Success:(void(^)(NewWalletModel *model))success Failure:(void(^)(NSError *error))failure{
    
    NSString *url = [NSString stringWithFormat:@"%@/api/custom/account",IP];

    [HttpTool getUrlWithString:url parameters:nil success:^(id responseObject) {
        
        NSError *error = [HttpTool inspectError:responseObject];
        
        if (error == nil) {
            
            NewWalletModel *model = [NewWalletModel mj_objectWithKeyValues:responseObject[@"data"][@"items"]];
            
            success(model);
            
        }else{
            
            failure(error);
        }
        
    } failure:^(NSError *error) {
        
        failure(error);
    }];
}

#pragma mark - 判断有没有设置支付密码
- (void)getIfHaveSetTradingPassWordSucess:(void(^)(BOOL seted))success Failure:(void(^)(NSError *error))failure{
    
    NSString *url = [NSString stringWithFormat:@"%@/api/wallet/payPass",IP];
    
    [HttpTool getUrlWithString:url parameters:nil success:^(id responseObject) {
        
        NSError *error = [HttpTool inspectError:responseObject];
        
        if (error == nil) {
            
            NSString *data = responseObject[@"data"];
            
            if ([data intValue] == 1) {
                
                success(YES);
            }else{
                
                success(NO);
            }
            
        }else{
            
            failure(error);
        }
        
    } failure:^(NSError *error) {
        
        failure(error);
    }];
}

#pragma mark - 提现提示信息
- (void)getTXInfoSuccess:(void(^)(TXModel *model))success Failure:(void(^)(NSError *error))failure{
    
    NSString *url = [NSString stringWithFormat:@"%@/api/wallet/withdraw/info",IP];
    
    [HttpTool getUrlWithString:url parameters:nil success:^(id responseObject) {
        
        NSError *error = [HttpTool inspectError:responseObject];
        
        if (error == nil) {
            
            TXModel *model = [TXModel mj_objectWithKeyValues:responseObject[@"data"]];
            [NewWalletList sharedInstance].txModel = model;
            success(model);
            
        }else{
            
            failure(error);
        }
        
    } failure:^(NSError *error) {
        
        failure(error);
    }];
}
@end
